<template>
  <div class="page-box">
    <el-card class="page-box-card">
      <el-form
        :model="queryParams"
        ref="queryForm"
        size="small"
        label-width="108px"
        inline
      >
        <el-form-item label="随访人" prop="param.userName">
          <el-input
            v-model="queryParams.param.userName"
            placeholder="请输入随访人"
          ></el-input>
        </el-form-item>
        <!-- <el-form-item label="规则名称" prop="param.name">
          <el-input
            v-model="queryParams.param.name"
            placeholder="请输入规则名称"
          ></el-input>
        </el-form-item> -->
        <el-form-item label="建档日期" prop="param.putOnRecordTime">
          <el-date-picker
            v-model="queryParams.param.putOnRecordTime"
            type="daterange"
            align="right"
            unlink-panels
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="small"
            @click="handleQuery"
            >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="small" @click="resetQuery"
            >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table
        v-loading="loading"
        :data="dataList"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" align="center" fixed />
        <el-table-column
          type="index"
          label="序号"
          width="55"
          align="center"
          fixed
        />
        <el-table-column
          prop="userName"
          label="随访人"
          align="center"
          width="100"
        >
        </el-table-column>
        <el-table-column
          prop="submitted1"
          label="3个月随访已提交量"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="approved1"
          label="3个月随访审核通过量"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="submitted2"
          label="6个月随访已提交量"
          align="center"
        >
        </el-table-column>
        <el-table-column
          prop="approved2"
          label="6个月随访审核通过量"
          align="center"
        >
        </el-table-column>
        <el-table-column prop="overdue" label="超期未随访数量" align="center">
        </el-table-column>
        <el-table-column label="操作" align="center" fixed="right" width="160">
          <template slot-scope="scope">
            <el-button
              size="mini"
              type="text"
              icon="el-icon-tickets"
              @click="handleDetails(scope.row)"
              v-hasPermi="['system:dept:edit']"
              >已随访列表</el-button
            >
            <!-- <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
              @click="handleStatus(scope.row)"
              v-hasPermi="['system:dept:edit']"
              >重新审核</el-button
            > -->
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
import {
  getListFlupStrategy,
  inserFlupStrategy,
  updateFlupStrategy,
  deleteFlupStrategy,
  exportData,
} from "@/api/followUp/strategy";
export default {
  dicts: ["strategy_type", "strategy_danger_level"],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      selectionData: [],
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        param: {
          riskLevel: "",
          type: "",
        },
      },
      tagList: [],
      dataList: [],
      total: 0,
    };
  },
  created() {
    this.getList();
  },
  methods: {
    // 导出数据
    downloadData() {
      const that = this;
      this.$modal
        .confirm("是否确认导出当前查询条件下的数据？")
        .then(function () {
          // 导出
          const params = that.queryParams;
          return that.download(
            exportData,
            { ...params.param },
            `策略_${new Date().getTime()}.xlsx`
          );
        })
        .then((res) => {
          that.$message.success("导出成功");
        })
        .catch(() => {});
    },
    // 搜索事件
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    // 重置事件
    resetQuery() {
      this.dataList = [];
      this.total = 0;
      this.queryParams.pageNum = 1;
      this.queryParams.pageSize = 10;
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 获取数据列表
    getList() {
      this.loading = true;
      // const param = { ...this.queryParams };
      // getListFlupStrategy(param).then((response) => {
      //   this.dataList = response.data.list;
      //   this.total = response.data.total;
      this.dataList = [
        {
          userName: "张三",
          submitted1: "1", // 3个月随访已提交量
          approved1: "1", // 3个月随访审核通过量
          submitted2: "0", // 6个月随访已提交量
          approved2: "0", // 6个月随访审核通过量
          overdue: "0", // 超期未随访数量
          fileNum: "test001", // 档案号
          fileType: "0", // 档案类型: 0 筛查档案随访,  1 住院档案随访
        },
        {
          userName: "李四",
          submitted1: "3", // 3个月随访已提交量
          approved1: "3", // 3个月随访审核通过量
          submitted2: "1", // 6个月随访已提交量
          approved2: "1", // 6个月随访审核通过量
          overdue: "0", // 超期未随访数量
          fileNum: "test002", // 档案号
          fileType: "1", // 档案类型: 0 筛查档案随访,  1 住院档案随访
        },
        {
          userName: "王五",
          submitted1: "7", // 3个月随访已提交量
          approved1: "6", // 3个月随访审核通过量
          submitted2: "2", // 6个月随访已提交量
          approved2: "1", // 6个月随访审核通过量
          overdue: "3", // 超期未随访数量
          fileNum: "test003", // 档案号
          fileType: "0", // 档案类型: 0 筛查档案随访,  1 住院档案随访
        },
      ];
      this.loading = false;
      // });
    },
    // 列表选中事件
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.selectionData = [...selection];
      this.single = selection.length != 1;
      this.multiple = !selection.length;
    },
    // 随访列表
    handleDetails(row) {
      console.log("row: ", row);
      const query = {
        fileNum: row.fileNum,
        userName: row.userName,
      };
      if (row.fileType == "0") {
        this.$router.push({ path: "/followUp/archives", query });
      } else if (row.fileType == "1") {
        this.$router.push({ path: "/followUp/already", query });
      }
      // this.title = "修改策略";
      // const data = row.id ? row : this.selectionData[0];
      // this.addForm = {
      //   ...data,
      //   roundList: data.round.split(","),
      // };
      // this.addDialog = true;
    },
  },
};
</script>
<style lang="scss">
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.row-1 {
  width: 20%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.row-3 {
  width: 80%;
  display: flex;
  align-items: center;
  justify-content: center;
}
</style>
